<template>
  <el-table :data="recordData" border>
    <el-table-column type="index" label="序号" align="center" width="50"></el-table-column>
    <el-table-column prop="operateTime" label="时间" align="center" width></el-table-column>
    <el-table-column prop="operateTypeStr" label="操作记录" align="center" width></el-table-column>
    <el-table-column label="用户名" prop="user.username" align="center"></el-table-column>
    <el-table-column prop="result" label="操作结果" align="center" width>
      <template slot-scope="scope">
        <span v-if="scope.row.result == 1">通过</span>
        <span v-else>不通过</span>
      </template>
    </el-table-column>
                <el-table-column prop="remark" label="备注" align="center" width=""></el-table-column>

  </el-table>
</template>


<script>
import {
  getApplyInfoByIdService,
  getOperateLogService,
  getPositionList
} from "service/task";
import { getLableFromList } from "../../../utils/common";
import { APPLY_STATUS_LIST } from "service/constant";
export default {
  props: ["taskId", "show"],
  data() {
    return {
      recordData: []
    };
  },
  watch: {
    show() {
      if (this.show == true) {
        getOperateLogService(this.taskId, 1, 500, "operateTime", "ASC").then(res => {
          console.log(res);
          if (res.data.success) {
            this.recordData = res.data.result.content;
            this.recordData.forEach(e => {
              e.operateTypeStr = getLableFromList(
                APPLY_STATUS_LIST,
                e.operateType
              );
            });
          }
        });
      }
    }
  },
  mounted() {
    if (this.show == true) {
      getOperateLogService(this.taskId, 1, 500, "operateTime", "ASC").then(res => {
        console.log(res);
        if (res.data.success) {
          this.recordData = res.data.result.content;
          this.recordData.forEach(e => {
            e.operateTypeStr = getLableFromList(
              APPLY_STATUS_LIST,
              e.operateType
            );
          });
        }
      });
    }
  }
};
</script>
